package com.ruoyi.biz.letter.read;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

/**
 * 操作类别字符串处理
 *
 * @author ruoyi
 */
@SuppressWarnings("rawtypes")
public class CityPurposeConverter implements Converter<String> {
    @Override
    public Class supportJavaTypeKey() {
        return Integer.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.STRING;
    }

    @Override
    public String convertToJavaData(ReadCellData cellData, ExcelContentProperty contentProperty,
                                    GlobalConfiguration globalConfiguration) {
        String value = "";
        String str = cellData.getStringValue();
        switch (str) {
            case "检举控告":
                value = "1";
                break;
            case "建议意见":
                value = "2";
                break;
            case "其他":
                value = "3";
                break;
            case "申诉求决_求决":
                value = "4";
                break;
            case "申诉求决_申诉":
                value = "5";
                break;
            default:
                value = "0";
                break;
        }
        return value;
    }

    @Override
    public WriteCellData convertToExcelData(String value, ExcelContentProperty contentProperty,
                                       GlobalConfiguration globalConfiguration) {
        String str = "";
        switch (value) {
            case "1":
                str = "检举控告";
                break;
            case "2":
                str = "建议意见";
                break;
            case "3":
                str = "其他";
                break;
            case "4":
                str = "申诉求决_求决";
                break;
            case "5":
                str = "申诉求决_申诉";
                break;
            default:
                str = "未知";
                break;
        }

        return new WriteCellData(str);
    }
}
